-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local validate = require 'mc.validate'
local utils = require 'mc.utils'
local mdb = require 'mc.mdb'

local Account = {}

---@class Account.RevokedDate
---@field RevokedDate string
local TRevokedDate = {}
TRevokedDate.__index = TRevokedDate
TRevokedDate.group = {}

local function TRevokedDate_from_obj(obj)
    return setmetatable(obj, TRevokedDate)
end

function TRevokedDate.new(RevokedDate)
    return TRevokedDate_from_obj({RevokedDate = RevokedDate})
end
---@param obj Account.RevokedDate
function TRevokedDate:init_from_obj(obj)
    self.RevokedDate = obj.RevokedDate
end

function TRevokedDate:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRevokedDate.group)
end

TRevokedDate.from_obj = TRevokedDate_from_obj

TRevokedDate.proto_property = {'RevokedDate'}

TRevokedDate.default = {''}

TRevokedDate.struct = {{name = 'RevokedDate', is_array = false, struct = nil}}

function TRevokedDate:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'RevokedDate', self.RevokedDate, 'string', true, errs, need_convert)

    TRevokedDate:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRevokedDate.proto_property, errs, need_convert)
    return self
end

function TRevokedDate:unpack(_)
    return self.RevokedDate
end

Account.RevokedDate = TRevokedDate

---@class Account.RevokedState
---@field RevokedState boolean
local TRevokedState = {}
TRevokedState.__index = TRevokedState
TRevokedState.group = {}

local function TRevokedState_from_obj(obj)
    return setmetatable(obj, TRevokedState)
end

function TRevokedState.new(RevokedState)
    return TRevokedState_from_obj({RevokedState = RevokedState})
end
---@param obj Account.RevokedState
function TRevokedState:init_from_obj(obj)
    self.RevokedState = obj.RevokedState
end

function TRevokedState:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRevokedState.group)
end

TRevokedState.from_obj = TRevokedState_from_obj

TRevokedState.proto_property = {'RevokedState'}

TRevokedState.default = {false}

TRevokedState.struct = {{name = 'RevokedState', is_array = false, struct = nil}}

function TRevokedState:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'RevokedState', self.RevokedState, 'bool', true, errs, need_convert)

    TRevokedState:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRevokedState.proto_property, errs, need_convert)
    return self
end

function TRevokedState:unpack(_)
    return self.RevokedState
end

Account.RevokedState = TRevokedState

---@class Account.IssuerId
---@field IssuerId integer
local TIssuerId = {}
TIssuerId.__index = TIssuerId
TIssuerId.group = {}

local function TIssuerId_from_obj(obj)
    return setmetatable(obj, TIssuerId)
end

function TIssuerId.new(IssuerId)
    return TIssuerId_from_obj({IssuerId = IssuerId})
end
---@param obj Account.IssuerId
function TIssuerId:init_from_obj(obj)
    self.IssuerId = obj.IssuerId
end

function TIssuerId:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TIssuerId.group)
end

TIssuerId.from_obj = TIssuerId_from_obj

TIssuerId.proto_property = {'IssuerId'}

TIssuerId.default = {0}

TIssuerId.struct = {{name = 'IssuerId', is_array = false, struct = nil}}

function TIssuerId:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'IssuerId', self.IssuerId, 'uint32', true, errs, need_convert)

    TIssuerId:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TIssuerId.proto_property, errs, need_convert)
    return self
end

function TIssuerId:unpack(_)
    return self.IssuerId
end

Account.IssuerId = TIssuerId

---@class Account.RootCertUploadedState
---@field RootCertUploadedState boolean
local TRootCertUploadedState = {}
TRootCertUploadedState.__index = TRootCertUploadedState
TRootCertUploadedState.group = {}

local function TRootCertUploadedState_from_obj(obj)
    return setmetatable(obj, TRootCertUploadedState)
end

function TRootCertUploadedState.new(RootCertUploadedState)
    return TRootCertUploadedState_from_obj({RootCertUploadedState = RootCertUploadedState})
end
---@param obj Account.RootCertUploadedState
function TRootCertUploadedState:init_from_obj(obj)
    self.RootCertUploadedState = obj.RootCertUploadedState
end

function TRootCertUploadedState:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRootCertUploadedState.group)
end

TRootCertUploadedState.from_obj = TRootCertUploadedState_from_obj

TRootCertUploadedState.proto_property = {'RootCertUploadedState'}

TRootCertUploadedState.default = {false}

TRootCertUploadedState.struct = {{name = 'RootCertUploadedState', is_array = false, struct = nil}}

function TRootCertUploadedState:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'RootCertUploadedState', self.RootCertUploadedState, 'bool', true, errs, need_convert)

    TRootCertUploadedState:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRootCertUploadedState.proto_property, errs, need_convert)
    return self
end

function TRootCertUploadedState:unpack(_)
    return self.RootCertUploadedState
end

Account.RootCertUploadedState = TRootCertUploadedState

Account.interface = mdb.register_interface('bmc.kepler.CertificateService.Certificate.Account', {
    RootCertUploadedState = {'b', {}, true, nil, false},
    IssuerId = {'u', {}, true, nil, false},
    RevokedState = {'b', {}, true, nil, false},
    RevokedDate = {'s', {}, true, nil, false}
}, {}, {})

return Account
